Install Debian (based) Linux Distributions in a Folder (chroot)

How to create a chroot (change root) in a secure way using mmdebstrap and systemd-nspawn.
Documentation for this is incomplete. Contributions are happily considered! See this for potential alternatives.
Contents
Chroot Use Cases[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Use_Cases
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Use_Cases|Chroot Use Cases]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Chroot Use Cases](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Use_Cases)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Chroot Use Cases](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Use_Cases)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Use_Cases]Chroot Use Cases[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
- See this list of chroot use cases in wikipedia
.
Chroot Security[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Security
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Security|Chroot Security]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Chroot Security](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Security)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Chroot Security](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Security)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Chroot_Security]Chroot Security[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
chroot is not a security feature.
Examples[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Examples
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Examples|Examples]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Examples](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Examples)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Examples](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Examples)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Examples]Examples[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
systemd-nspawn[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#systemd-nspawn
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#systemd-nspawn|systemd-nspawn]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[systemd-nspawn](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#systemd-nspawn)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[systemd-nspawn](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#systemd-nspawn)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#systemd-nspawn]systemd-nspawn[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
Introduction[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Introduction
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Introduction|Introduction]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Introduction](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Introduction)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Introduction](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Introduction)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Introduction]Introduction[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
Quote Changing Roots:
systemd-nspawn tool which acts as chroot(1) on steroids
it makes use of file system and PID namespaces to boot a simple lightweight container on a file system tree.
It can be used almost like chroot(1), except that the isolation from the host OS is much more complete, a lot more secure and even easier to use
systemd-nspawn is capable of booting a complete systemd or sysvinit OS in container with a single command.
- Booting of the container can take less than 3 seconds.
Security[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Security
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Security|Security]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Security](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Security)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Security](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Security)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Security]Security[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
Can systemd-nspawn
be made a secure jail? The following quote might be outdated and/or not reflect a "hardened container". Quote systemd lead developer:
Note however that this protects the host OS only from accidental changes of its parameters. A process in the container can manually remount the file systems read-writeable and then change whatever it wants to change.
What are these issues? Related to running root vs non-root inside the container? Can these security holes nowadays be closed?
Since we are inside a VM already, can containers be used for better security?
Quote systemd-nspawn man page:
--drop-capability=
Specify one or more additional capabilities to drop for the container. This allows running the container with fewer capabilities than the default (see above).
Quote https://wiki.archlinux.org/index.php/systemd-nspawn#Creating_private_users_(unprivileged_containers)
systemd-nspawn supports unprivileged containers,
Great!
, though the containers need to be booted as root.
That could be an OK limitation?
See also:
- https://unix.stackexchange.com/questions/145739/what-makes-systemd-nspawn-still-unsuitable-for-secure-container-setups
- https://opensource.com/business/14/7/docker-security-selinux
- https://people.kernel.org/brauner/runtimes-and-the-curse-of-the-privileged-container
Exit systemd-nspawn[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Exit_systemd-nspawn
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Exit_systemd-nspawn|Exit systemd-nspawn]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Exit systemd-nspawn](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Exit_systemd-nspawn)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Exit systemd-nspawn](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Exit_systemd-nspawn)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Exit_systemd-nspawn]Exit systemd-nspawn[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
To leave the chroot press keep holding key CTRL
and press key 5
quickly 3 times within 1 second. [1]
See Also[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#See_Also
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#See_Also|See Also]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[See Also](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#See_Also)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[See Also](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#See_Also)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#See_Also]See Also[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
- https://wiki.archlinux.org/index.php/systemd-nspawn
- https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html
LXC[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#LXC
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#LXC|LXC]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[LXC](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#LXC)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[LXC](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#LXC)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#LXC]LXC[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
https://wiki.archlinux.org/index.php/Linux_Containers#Enable_support_to_run_unprivileged_containers_(optional)
mmdebstrap[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#mmdebstrap
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#mmdebstrap|mmdebstrap]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[mmdebstrap](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#mmdebstrap)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[mmdebstrap](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#mmdebstrap)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#mmdebstrap]mmdebstrap[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
mmdebstrap
is a tool that can be used to securely create chroots.
Using debootstrap
is insecure at times such as if APT is vulnerable and the fixed package only available from security.debian.org APT repository not the regular Debian repository because it can use only 1 APT repository at a time. And security.debian.org does not include all packages created to create a chroot.
A secure alternative is mmdebstrap
. [2] See also other advantages of mmdebstrap
.
TODO[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#TODO
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#TODO|TODO]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[TODO](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#TODO)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[TODO](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#TODO)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#TODO]TODO[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
- xchroot
: chroot for users with Xorg/X11 forwarding and automatic mounting + aufs/unionfs read only root support.
- Needs cautious review. Same author as debcheckroot
which does not do gpg signature verification of downloaded package metadata because thinks
that's useless.
- Needs cautious review. Same author as debcheckroot
- Gentoo wiki has instructions for launching Wayland applications from a chroot: https://wiki.gentoo.org/wiki/Chroot#Wayland
Footnotes[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Footnotes
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Footnotes|Footnotes]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Footnotes](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Footnotes)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Footnotes](https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Footnotes)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Installation_of_Debian_based_Linux_distributions_in_a_folder_chroot#Footnotes]Footnotes[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
- ↑
https://unix.stackexchange.com/questions/577065/connected-to-container-mycontainer-press-three-times-within-1s-to-exit-sessi
- ↑ alternative is multistrap (might be outdated, author has no experience with it)


Copy as Wikitext

for Discourse, reddit, GitHub

Copy as Markdown

Copy as phpBB Click below ↴ = Open social URL with share data











We believe security software like Kicksecure needs to remain Open Source and independent. Would you help sustain and grow the project? Learn more about our 12 year success story and maybe DONATE!